{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Day 7 Agenda \n",
    "\n",
    "1. OOPs - inheritance and Polymorphism\n",
    "2. Libraries and Packages \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Parent Class \n",
    "class animal():\n",
    "    def __init__(self,eat, talk, breed):\n",
    "        self.eat = eat\n",
    "        self.talk = talk\n",
    "        self.breed = breed\n",
    "    def getAnimal(self):\n",
    "        print(\"Breed - \", self.breed)\n",
    "        print(\"Eats - \", self.eat)\n",
    "        print(\"Talks - \",self.talk)\n",
    "    \n",
    "    def setLegs(self):\n",
    "        raise NotImplementedError(\"Hey We need you to implement Set Legs in Child Class \")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Child Class \n",
    "class dog(animal):\n",
    "    def __init__(self, name):\n",
    "        animal.__init__(self,\"Carnivores\",  \"Bow Bow\",\"Dog - Bulldog\")\n",
    "        self.name = name\n",
    "    def getName(self):\n",
    "        print(self.name)\n",
    "    def setLegs(self):\n",
    "        print(\"Dog has 4 legs\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [],
   "source": [
    "tommy = dog(\"Tommy\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Dog has 4 legs\n"
     ]
    }
   ],
   "source": [
    "tommy.setLegs()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [],
   "source": [
    "class cat(animal):\n",
    "    def __init__(self,name):\n",
    "        animal.__init__(self,\"Fish\",\"Meow\",\"cat\" )\n",
    "        self.name = name \n",
    "    def getCatName(self):\n",
    "        print(self.name)\n",
    "    def setLegs(self):\n",
    "        print(\"Cat has 4 Legs\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [],
   "source": [
    "mino = cat(\"mino\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Breed -  cat\n",
      "Eats -  Fish\n",
      "Talks -  Meow\n"
     ]
    }
   ],
   "source": [
    "mino.getAnimal()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cat has 4 Legs\n"
     ]
    }
   ],
   "source": [
    "mino.setLegs()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Polymorphism "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Same name but different tasks \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Jambo African Elephant Says D. Trump\n",
      "Alexandar percheron Says Tarun\n"
     ]
    }
   ],
   "source": [
    "class Animal():\n",
    "    def __init__(self,name,breed):\n",
    "        self.name = name \n",
    "        self.breed = breed\n",
    "    \n",
    "    def speak(self):\n",
    "        raise NotImplementedError(\"Sub Class Must Implement Speak Method\")\n",
    "        \n",
    "\n",
    "class Elephant(Animal):\n",
    "    def speak(self):\n",
    "        return self.name + self.breed + ' Says D. Trump'\n",
    "\n",
    "\n",
    "class Horse(Animal):\n",
    "    def speak(self):\n",
    "        return self.name + self.breed+ ' Says Tarun'\n",
    "    \n",
    "Jambo = Elephant('Jambo',' African Elephant')\n",
    "Alexandar = Horse('Alexandar',' percheron')\n",
    "\n",
    "print(Jambo.speak())\n",
    "print(Alexandar.speak())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "class Animal():\n",
    "    def __init__(self,name,breed):\n",
    "        self.name = name \n",
    "        self.breed = breed\n",
    "    \n",
    "    def speak(self):\n",
    "        raise NotImplementedError(\"Sub Class Must Implement Speak Method\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [],
   "source": [
    "class shape():\n",
    "    def __init__(self, name):\n",
    "        self.name = name\n",
    "    def area(self):\n",
    "        raise NotImplementedError(\"Hey Define a Area  function for this class\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [],
   "source": [
    "class circle(shape):\n",
    "    def __init__ (self, radius):\n",
    "        shape.__init__(self,\"circle\")\n",
    "        self.radius = radius\n",
    "    def area(self):\n",
    "        print(\"Area of Circle - \", 3.14*self.radius*self.radius)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [],
   "source": [
    "class square(shape):\n",
    "    def __init__ (self, sides):\n",
    "        shape.__init__(self,\"Square\")\n",
    "        self.sides = sides\n",
    "    def area(self):\n",
    "        print(\"Area of Square - \", self.sides*self.sides)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [],
   "source": [
    "abc = square(4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Area of Square -  16\n"
     ]
    }
   ],
   "source": [
    "abc.area()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Modules And Packages "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
